#ifndef ABSTRACTMODULE_H
#define ABSTRACTMODULE_H

#include "filebased.h"
#include "abstractdat.h"
#include "dlgbasedqt.h"
#include "pkey.h"
#include "savingstate.h"

#include <map>
#include <string>

using namespace std;

class AbstractModule:
        virtual public FileBased,
        virtual public AbstractDat,
        virtual public DlgBasedQt,
        virtual public SavingState
{
public:
    AbstractModule();
    ~AbstractModule();

    // Serve ad annullare i dati inseriti partendo da un default
    virtual void    resetModule ( void );

    void   setModuleKey ( const PKey &key );
    void   setModuleKey ( const string &key );
    void setModuleDescr ( const string &descr );

    virtual string   getModuleKey ( void ) const;
    virtual string getModuleDescr ( void ) const;

    virtual PKey* getModulePointerKey ( void ) const;

    void setIndexOfModuleList ( int index );
     int getIndexOfModuleList ( void ) const;

    // Overridding for [AbstractDat]
    virtual void setInstalledDat ( bool b );
    virtual ExaModuleObj getModuleDat ( void ) const; // = 0

    // Restituisce il puntatore al modulo.
    static AbstractModule* getModule( ExaModuleObj m);

    typedef map < ExaModuleObj, AbstractModule* > map_ModuleObj_DatPointer;

    // Overridding for [SavingState]
    virtual void    save ( void ); // = 0
    virtual void restore ( void ); // = 0

    // Overridding for [DlgBasedQt]
    virtual int dlgExec ( void );

protected:
    virtual string buildDlgTitle ( void ) const;
    void renameLinkedFileList ( void ) const;

private:
    int m_index_of_moduleList;

    PKey *m_p_key;       // chiave e descrizione del modulo
    PKey  m_p_key_cache; //

    static  map_ModuleObj_DatPointer m_map_module_dat;
    static  map_ModuleObj_DatPointer init_map_module_dat();
};

#endif // ABSTRACTMODULE_H
